package com.lkl.chat.model.entity;

import com.lkl.chat.config.SparkConfig;
import com.lkl.chat.socket.SparkChatListener;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

/**
 * 星火聊天类
 */
@Slf4j
@Data
public class SparkChat extends SparkChatListener {
    private String userId;
    private String question;
    private String host;
    private String path;
    private String appid;
    private String apiSecret;
    private String apiKey;
    private String domain;

    public SparkChat(SparkConfig sparkConfig, String userId, String question) {
        super(new StringBuilder());
        this.userId = userId;
        this.question = question;
        this.apiKey = sparkConfig.getApiKey();
        this.apiSecret = sparkConfig.getApiSecret();
        this.appid = sparkConfig.getAppId();
        if (sparkConfig.getModelVersion() != null && sparkConfig.getModelVersion().length() > 0) {
            this.host = sparkConfig.getHostInfos().get(Integer.parseInt(sparkConfig.getModelVersion()) - 1).getHost();
            this.path = sparkConfig.getHostInfos().get(Integer.parseInt(sparkConfig.getModelVersion()) - 1).getPath();
            this.domain = sparkConfig.getHostInfos().get(Integer.parseInt(sparkConfig.getModelVersion()) - 1).getDomain();
        } else {
            this.host = sparkConfig.getDefaultHostInfo().getHost();
            this.path = sparkConfig.getDefaultHostInfo().getPath();
            this.domain = sparkConfig.getDefaultHostInfo().getDomain();
        }
    }
}

